///////////////////////////////////////////////////////////////////////////////
// Class C_elf                                                               //
// Created by Hell Hibou (2008)                                              //
// Part of Wii Homebrew Launcher                                             //
// based on sources of William L. Pitts (2001) and Felix Domke (2004)        //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////


#ifndef _CLASS_UOBIHLLEH_C_APP_ELF
#define _CLASS_UOBIHLLEH_C_APP_ELF

#include "app.hpp"

#define APP_TYPE_ELF	2

class C_App_elf: public C_App
{
	public:
		static bool  isElf (const void * elf);
		void * Load (const void *, const char * CommandLine = NULL, const u8 Action = APP_ACTION_RUN);
	
	private:
		typedef struct eHeader
		{
			unsigned char	e_ident[16]; /* ELF Identification */
			u16				e_type;		 /* object file type */
			u16				e_machine;	 /* machine */
			u32				e_version;	 /* object file version */
			u32				e_entry;	 /* virtual entry point */
			u32				e_phoff;	 /* program header table offset */
			u32				e_shoff;	 /* section header table offset */
			u32				e_flags;	 /* processor-specific flags */
			u16				e_ehsize;	 /* ELF header size */
			u16				e_phentsize; /* program header entry size */
			u16				e_phnum;	 /* number of program header entries */
			u16				e_shentsize; /* section header entry size */
			u16				e_shnum;	 /* number of section header entries */
			u16				e_shstrndx;	 /* section header table's "section header string table" entry offset */
		};
		
		typedef struct sHeader
		{
			u32	sh_name;	    /* name - index into section header string table section */
			u32	sh_type;	    /* type */
			u32	sh_flags;	    /* flags */
			u32	sh_addr;	    /* address */
			u32	sh_offset;	    /* file offset */
			u32	sh_size;	    /* section size */
			u32	sh_link;	    /* section header table index link */
			u32	sh_info;	    /* extra information */
			u32	sh_addralign;	/* address alignment */
			u32	sh_entsize;	    /* section entry size */
		};	
};

#endif

///////////////////////////////////////////////////////////////////////////////
